package main

import (
	"fmt"
	"sync"
	"time"
)

type Mutex struct {
	sync.Mutex
}

func (m *Mutex) Get(i int, f func() error) {
	m.Lock()
	fmt.Printf("我[ %d ]拿到了锁", i)
	defer m.Unlock()
	if err := f(); err != nil {
		fmt.Println(err)
	}
	time.Sleep(1 * time.Second)
}
func main() {
	m := &Mutex{}
	for i := 0; i < 10; i++ {
		i := i
		m.Get(i, f func() error)
	}
}
